﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DBO.Utility;
using CustomControls;

namespace WinFormClient
{
    public partial class LoginForm : Form
    {
        private static PasswordForgottenForm PassForm;
        public LoginForm()
        {
            InitializeComponent();
        }

        public void CenterForm()
        {
            this.CenterToScreen();
        }

        public PLICCredentials Content { get; set; }
        public string Error
        {
            get
            {
                return ErrorLabel.Text;
            }
            set
            {
                ErrorLabel.Text = value;
            }
        }

        public event EventHandler onLogIn;
        public event EventHandler onPassSend;

        private void LogInButton_Click(object sender, EventArgs e)
        {
            Content.Login = LoginField.Text;
            Content.Password = PassField.Text;

            onLogIn.Invoke(this, null);
        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void QuitButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void ForgottenPassLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            PassForm = new PasswordForgottenForm();

            PassForm.Show();

            PassForm.onSend += new EventHandler(PassForm_onSend);
        }

        void PassForm_onSend(object sender, EventArgs e)
        {
            onPassSend.Invoke(sender, e);
            PassForm.Close();
        }
    }
}
